import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../util/http.dart';
import '../../model/result.dart';

part 'home_mine_state.dart';

class HomeMineCubit extends Cubit<HomeMineState> {
  HomeMineCubit() : super(HomeMineState()) {
    requestData();
  }

  requestData() async {
    var result = await post('/mock/64bf2b2bb9e270cc51cbf95d/example/mock');
    var data = Data.fromJson(result.data);
    debugPrint('$data');
    emit(state.clone(projects: data.projects));
  }

  scan(BuildContext context) {
    Navigator.pushNamed(context, 'scan');
  }
}
